Ext.define("testleo.controller.Main", {
    extend: "Ext.app.Controller",
    
    requires: [
        'Ext.device.Communicator',
        // 'Ext.device.geolocation.PhoneGap',
        'Ext.device.geolocation.Sencha',
        'Ext.device.geolocation.Simulator'
    ],
    
    
    config: {
        refs: {
            blog: 'blog'
        },
        control: {
            'blog list': {
                itemtap: 'showPost'
            }
        }
    },
    
    showPost: function(list, index, element, record) {
        //console.log('tapped!'),
        //console.log(record.get('title'))
        this.getBlog().push({
            xtype: 'panel',
            title: record.get('title'),
            html: record.get('content'),
            scrollable: true,
            styleHtmlContent: true
        })
    },
    
    launch: function (app) {
        console.log("launch");
        //console.log("Phone " + Ext.is.Phone);
        //console.log("Desktop " + Ext.is.Desktop);
        //console.log("orientation " + Ext.orientation);
        console.log("Phone " + Ext.os.is('Phone'));
        console.log("Desktop " + Ext.os.is('Desktop'));
        console.log("Tablet " + Ext.os.is('Tablet'));
        
        var geoReady = navigator.geolocation || undefined;
        //Ext.device.Geolocation.getCurrentPosition({
        //    success: function(position) {
        //        console.log(position.coords);
        //        console.log(geoReady.coords);
        //    },
        //    failure: function() {
        //        console.log('something went wrong!');
        //    }
        //});
        //console.log(geoReady.coords);
        
        var geoReady = navigator.geolocation || undefined;
        if (geoReady) {
            var onSuccess = function(position) {
                //Pass the location to the proxy and update the store
                //Ext.getCmp('gisStatus').setLocation(position.coords.latitude, position.coords.longitude);
                console.log(position.coords.latitude, position.coords.longitude);
            };
            function onError(error) {
                console.log("Unable to get position");
            }
            navigator.geolocation.getCurrentPosition(onSuccess, onError);
        }
        
    }
});